1. Using modelflow with World Bank models#

The Modelflow python package has been developed to solve a wide range of models, see the modelflow github web site for working examples of the Solow Model, the FR/USB model and others.

The package has been substantially expanded to include special features that enable it to work with World Bank models originally developed in EViews and designed to use EViews Model Object for simuation.

This chapter illustrates how to access these models, how to load them into a modelflow anaconda environment on your computer and how to perform a variety of simulations

1.1. Accessing a world bank model#

At this time several World bank macrostructural models are available to download and use with modelflow. These include a macrostructural model for:

  • Indonesia

  • Nepal

  • Croatia

  • Iraq

  • Kenya

  • Bolivia

Each of these models has been developed as part of the outreach work of the World Bank. The basic modelling framework of each of these models is outlined in Burns et al. [2019] with specific extensions reflecting features of the individual country modelled.

This book uses as an example a climate aware model for Pakistan developed in 2020 and described in Burns et al. [2021] .

The World Bank models are distributed in the pcim file format of the modelflow and can be downloaded by right clicking on the links above. The Pakistan model can be downloaded here by right clicking on the above link and selecting Save Link as and placing the file on a directory accessible by your modelflow installation.

Question

Ib can't we have a package WorldBankMFModModels that one could import?  I seem to see this for other packages that have geographic data on countries or their population.   

I imagining something like:

from worldbankMFModModels import pak

Ansver

As of now, a model which is not located in the specified path will be sought in a global model repo on github. The user can specify any URL where the model is located instead, or a URL for a repo which is seached for the model name. So, if I am not wrong it is better to place each model at some location instead of creating a python packagde where all models are located,

1.2. Preparing your python environment#

As always, the modelflow and other python packages that will be used need to be imported into your python session. The examples here and this book were written and solved in a Jupyter Notebook. There are some Jupyter specific commands included in these examples and these are annotated. However, the bulk of the content of the programs can be run in other environments, including Interactive Development Environments (IDE) like Spyderor MS Visual Code. All the programs have been tested under spyder as well as Jupyter Notebook.

It is assumed that:

  1. you have already installed modelflow and its various support packages following the instructions in Chapter xx

  2. you are using Anaconda, and that

  3. you have activated your modelflow environment by executing the following command from your python command line:

conda activate modelflow

where modelflow is the name you have given to the conda environment into which you installed modelflow.

2. Working with PakMod under modelflow#

The basic method for working with any model is the same. Indeed the initial steps followed here are the same as were followed during the simple model discussion.

Process:

  1. Prepare the workspace

  2. Load the model Modelflow

  3. Design some scenarios

  4. Simulate the model

  5. Visualize the results

2.1. Load a pre-existing model, data and descriptions#

To load a model use the model.modelload() method of modelflow.

The command below

mpak,bline = model.modelload('..\models\pak.pcim', alfa=0.7,run=1,keep= 'Baseline')

instantiates (creates an instance of) a modelflow model object and assigns it to the variable name mpak. The run=1 option executes the model and assigns the result of the model execution to the dataframe bline. The model is solved with the parameter alfa set to 0.7. The \(alfa \in (0,1)\) parameter determines the step size of the solution engine. The larger alfa the larger the step size. Larger step sizes may solve faster, but may have trouble finding a unique solution. Smaller step sizes take longer to solve but are more likely to find a unique solution. Values of alfa=.7 work well for World Bank models.

The keep option instructs modelflow to maintain in the model object (mpak) the results of the initial scenario, assigning it the text name Baseline.

Note

If modelflow cannot find the file at the position indicated it will look it the global Model repository where some models are stored.

#Replace the path below with the location of the pak.pcim file on your computer
mpak,bline = model.modelload('..\models\pak.pcim', \
                                alfa=0.7,run=1,keep= 'Baseline')
file read:  C:\modelflow manual\papers\mfbook\content\models\pak.pcim

Note

the variable bline contains the dataframe with the results of the simulation. This is distinct from the data that is stored by the keep= command. That said, the data associated with each, while stored separately, have the same numerical values. The keep option is described in more detail toward the end of this section.

3. Extracting information about the model#

The newly loaded python object mpak is an instance of the model class and as such inherits the methods (functions) and properties (data) of that class. To learn about the model there are a variety of methods that can be used to extract information about the model and its data.

A World Bank model in modelflow will contain a wide range of objects.

  • variables – time series variables comprised of mnemonics and data

  • variables descriptions – when avaiable

  • dataframes – data for each variable generated in different simulations

  • groups – lists of variables

  • equations – identities and behaviourals

  • model – the model object itself

Extracting information about each of these objects is central to working with WBG models in modelflow.

3.1. Model information#

The model object contains information about the model itself, its name, its structure (does it contain simultaneous equations or is it recursive), the number of variables it contains and the number that are exogenous and endogenous (have associated equations).

mpak
<
Model name                              :                  PAK 
Model structure                         :         Simultaneous 
Number of variables                     :                  839 
Number of exogeneous  variables         :                  461 
Number of endogeneous variables         :                  378 
>

The model work space also has a time dimension, its sample period. This can be retrieved and changed. The current time dimension is contained in the variable `mpak.per_current’

mpak.current_per
Index([2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026, 2027,
       2028, 2029, 2030],
      dtype='int64')
mpak.model_description="World Bank climate aware model of Pakistan as described in Burns et al. (2019)"
mpak.model_description
'World Bank climate aware model of Pakistan as described in Burns et al. (2019)'

3.2. Information about variables#

The model object mpak contains lists of all the variables that form part of the model, and these lists can be interrogated to garner information about the model. The Table below indicates some of the most important of these. The variables for which information is sought can be specified directly or through a wildcard specification (see note).

Method

Example

Information returned

.names

modelname['PAKNECON*XN].name

returns a python list of the mnemnics of all the variables defined and contained in the model object that match the search pattern in the []

.des

modelname['PAKNECONPRVT?N'].des

returns a list of mnemonics and their variable descriptions

.<var name>.show

modelname.PAKNECONPRVTXN.show

Lists the equation (formula), variable descriptions and variable values

Note

Wildcards

Most of the information commands accept wildcard specifications in the search parameter.

The * character in the command mpak['PAKNECON*XN'].names example is a wildcard character and the expression will return all variables that begin PAKNECON and end XN.

The ? in the .des example is another wildcard expression. It will match only single characters. Thus mpak['PAKNECONPRVT?N'].names would return three variables: PAKNECONPRVTKN, PAKNECONPRVTXN, and PAKNECONPRVTXN. The real, current value, and deflators for household consumption expenditure.

Note the final show example uses a slightly different syntax where the variable to be operated upon is specified directly: modelname.PAKNECONPRVTXN.show.

The example below returns the mnemonics and descriptions of all variables matching the pattern PAKNYGDP*KN, i.e. Pakistani variables from the National Income Accounts from the main sub-category GDP that are also real variables.

mpak['PAKNYGDP*KN'].des
PAKNYGDPDISCKN : GDP Disc., 2000 LCU mn
PAKNYGDPFCSTKN : GDP Factor Cost Local Currency units Volumes National base year
PAKNYGDPMKTPKN : Real GDP
PAKNYGDPPOTLKN : Potential Output, constant LCU

Box [^BoxWBMnemonics]: World Bank Mnemonics

A typical World Bank model will have in excess of 300 variables. Each has a mnemonic that is structured in a specific way, The root for almost all are 14 characters long (some special variables have additional characters appended to this root) (see discussion in section).

\[\texttt{12345678901234}\]
\[\color{green}{\texttt{CCC}}\color{red}{\texttt{AA}}\color{lime}{\texttt{MMM}}\color{blue}{\texttt{NNNN}}\color{magenta}{\texttt{U}}\color{black}{\texttt{C}}\]

where:

Letters

Meaning

\(\color{green}{\texttt{CCC}}\)

The three-leter ISO code for a country – i.e. IDN for Indonesia, RUS for Russia

\(\color{red}{\texttt{AA}}\)

The two-letter major accounting system to which the variable attaches,

\(\color{lime}{\texttt{MMM}}\)

The three-letter major sub-category of the data - i.e. GDP, EXP - expenditure

\(\color{blue}{\texttt{NNNN}}\)

The four-letter minor sub-category MKTP for market prices

\(\color{magenta}{\texttt{U}}\)

The measure (K: real variable;C: Current Values; X: Prices)

\(\color{black}{\texttt{C}}\)

denotes the Currency (N: National currency; D: USD; P: PPP)

Common major accounting systems mnemonics: the, \(\color{red}{\texttt{AA}}\)s from above:

Code

Meaning

NY

National income

NE

National expenditure Accounts

NV

Value added accounts

GG

General Government Accounts

BX

Balance of Payments: Exports

BM

Balance of Payments: Imports

BN

Balance of Payments: Net

BF

Balance of Payments: Financial Account

Thus

Mnemonic

Meaning

IDNNYGDPMKTPKN

Indonesia GDP at market prices, real in Indonesian Rupiah

KENNECPNPRVTXN

Kenya Private (household) consumption expenditure schillings deflator

BOLGGEXPGNFSCN

Bolivia Government Expenditure on Goods and services (GNFS) in current Bolivars

HRVGGREVDCITCN

Croatia Government Revenues Direct Corporate Income Taxes in current Euros

NPLBXGSRNFSVCD

Nepal BOP Exports of non-factor services (goods and services) in current USD

If executed, the command mpak['*'].des would return a dictionary of all the mnemonics and descriptions of all the variables in the mpak model object.

3.2.1. The ! operator – searching on the variable description#

The same methods can be used to retrieve information about variables, based on their descriptions (vs mnemonic), by pre-pending the search string with the ! operator.

Note

The ! operator If a wildcard is preceded by an exclamation mark ! the search will be done over the description of variables instead of the mnemonic

The below expression returns all variables whose description includes the word Carbon.

mpak['!*Carbon*'].des
PAKGGREVCO2CER : Carbon tax on coal (USD/t)
PAKGGREVCO2GER : Carbon tax on gas (USD/t)
PAKGGREVCO2OER : Carbon tax on oil (USD/t)

3.3. Groups#

Modelflow inherits a variant of the idea of groups from EViews. In modelflow the groups defined in an imported EViews workfile are converted into entries in a dictionary called var_groups which can be interrogated, added to and amended like any dictionary in python.

The command mpak.var_groups will return all of the groups already defined in mpak.

mpak.var_groups
{'Headline': '???GDPpckn ???NRTOTLCN ???LMEMPTOTL ???BFFINCABDCD  ???BFBOPTOTLCD ???GGBALEXGRCN ???BNCABLOCLCD_ ???FPCPITOTLXN',
 'National income accounts': '???NY*',
 'National expenditure accounts': '???NE*',
 'Value added accounts': '???NV*',
 'Balance of payments exports': '???BX*',
 'Balance of payments exports and value added ': '???BX* ???NV*',
 'Balance of Payments Financial Account': '???BF*',
 'General government fiscal accounts': '???GG*',
 'World all': 'WLD*',
 'PAK all': 'PAK*'}

A group can be added to the dictionary by giving it a unique identifier (key) and associating with it a string defining the group, using a wildcard specification or just a space de-limited list of mnemonics.

Thus the command

mpak.var_groups['Mygroup]='PAKGGREV*CN PAKGGEBALOVRLCN'

Will create a new group containing the variables matching the pattern

mpak.var_groups['Mygroup']='PAKGGREV*CN PAKGGEBALOVRLCN'
                
mpak['#Mygroup'].names
['PAKGGREVDRCTCN',
 'PAKGGREVEMISCN',
 'PAKGGREVGNFSCN',
 'PAKGGREVGRNTCN',
 'PAKGGREVOTHRCN',
 'PAKGGREVTOTLCN',
 'PAKGGREVTRDECN']

3.4. Information about data#

Note the same search functions can be used to display the data associated with the returned variables.

Thus to see the data for the Mygroup group of variables, one could use the .df method or .plot() methods – here modified by pct (to show growth rates) and mul100 to multiply them by 100 to display them as percent change.

mpak['#Mygroup'].pct.mul100.plot()
../../_images/1d2f04bb581f8d29beb1f0e3b2e49b09c51c3e2c0d137a42ee517a0517b6affd.png

Below the same logic is used to display the data from variables matching a mnemonic search. The results have been placed inside a with m[pak.set_smpl() clause to restrict the output to a shorter period. If it was not used the output would cover the whole time period of the .lastdf DataFrame from which all of this data is drawm.

with mpak.set_smpl(2020,2024):
    print(round(mpak['#Mygroup'].pct.mul100.df,2))
      PAKGGREVDRCTCN  PAKGGREVEMISCN  PAKGGREVGNFSCN  PAKGGREVGRNTCN   
2020           13.30            1.10           13.25           39.48  \
2021           11.69            0.21           11.33           29.52   
2022           10.48            0.28           10.11           23.40   
2023            9.84            0.82            9.60           19.62   
2024            9.48            1.42            9.36           17.09   

      PAKGGREVOTHRCN  PAKGGREVTOTLCN  PAKGGREVTRDECN  
2020           17.83           16.77           18.25  
2021           15.34           14.39           15.28  
2022           13.45           12.69           13.71  
2023           12.29           11.72           12.89  
2024           11.51           11.10           12.35  

Jupyter truncates the output by showing the first and last five observations of the active sample period when the same call is made without the with clause.

mpak.smpl(2000,2100)
print(round(mpak['#Mygroup'].pct.mul100.df,2))
      PAKGGREVDRCTCN  PAKGGREVEMISCN  PAKGGREVGNFSCN  PAKGGREVGRNTCN   
2000            9.55          101.83           70.02             NaN  \
2001           11.14           15.37           31.46             inf   
2002           14.66          -13.23            8.55           94.82   
2003            7.11           35.47           17.12          -36.96   
2004            8.43           21.64           13.05          -39.98   
...              ...             ...             ...             ...   
2096            9.03            2.84            9.07            9.03   
2097            9.02            2.84            9.06            9.02   
2098            9.02            2.84            9.06            9.02   
2099            9.01            2.84            9.06            9.01   
2100            9.01            2.84            9.05            9.01   

      PAKGGREVOTHRCN  PAKGGREVTOTLCN  PAKGGREVTRDECN  
2000             NaN            7.30          -21.68  
2001             inf           16.34            5.52  
2002           17.59           22.84          -26.44  
2003           15.20            6.04           43.96  
2004           26.30           15.68           32.11  
...              ...             ...             ...  
2096            9.03            9.03            8.96  
2097            9.02            9.02            8.96  
2098            9.02            9.02            8.95  
2099            9.01            9.02            8.95  
2100            9.01            9.01            8.95  

[101 rows x 7 columns]

3.4.1. Some examples#

3.4.1.1. .names property#

mpak['PAKNECON*XN'].names

Return the names (mnemonmics) of all variables that begin PAKNECON and end XN – i.e. Price deflators for various types of consumption demand.

mpak['PAKNECON*XN'].names
['PAKNECONENGYXN', 'PAKNECONGOVTXN', 'PAKNECONOTHRXN', 'PAKNECONPRVTXN']

3.4.1.2. The .des property#

mpak['PAKNECONPRVT?N'].des

Returns a dictionary comprised of the mnemonics and the descriptions of all the variables that begin PAKNECONPRVT and end N, but have only one character between the T and the N.

mpak['PAKNECONPRVT?N'].des
PAKNECONPRVTCN : Pvt. Cons., LCU mn
PAKNECONPRVTKN : HH. Cons Real
PAKNECONPRVTXN : Implicit LCU defl., Pvt. Cons., 2000 = 1

3.4.1.3. .var_description method#

The property .var_descriptionreturns a dictionaryy with descriptions of all variables. Modified to a specific variable it returns the description of that one variable. As a dictionary it do not accept wildcards as arguments.

#mpak.var_description # returns the descirptions for all variables
mpak.var_description['PAKNYGDPMKTPCN'] # returns the description of a specific variable
'GDP, Market Prices, LCU mn'

3.5. Information about equations#

For endogenous variables the property: .<variable name>.frml returns informations on the equation for the variable.

mpak.PAKNECONPRVTKN.frml
Endogeneous: PAKNECONPRVTKN: HH. Cons Real
Formular: FRML <DAMP,STOC> PAKNECONPRVTKN = (PAKNECONPRVTKN(-1)*EXP(PAKNECONPRVTKN_A+ (-0.2*(LOG(PAKNECONPRVTKN(-1))-LOG(1.21203101101442)-LOG((((PAKBXFSTREMTCD(-1)-PAKBMFSTREMTCD(-1))*PAKPANUSATLS(-1))+PAKGGEXPTRNSCN(-1)+PAKNYYWBTOTLCN(-1)*(1-PAKGGREVDRCTXN(-1)/100))/PAKNECONPRVTXN(-1)))+0.763938860758873*((LOG((((PAKBXFSTREMTCD-PAKBMFSTREMTCD)*PAKPANUSATLS)+PAKGGEXPTRNSCN+PAKNYYWBTOTLCN*(1-PAKGGREVDRCTXN/100))/PAKNECONPRVTXN))-(LOG((((PAKBXFSTREMTCD(-1)-PAKBMFSTREMTCD(-1))*PAKPANUSATLS(-1))+PAKGGEXPTRNSCN(-1)+PAKNYYWBTOTLCN(-1)*(1-PAKGGREVDRCTXN(-1)/100))/PAKNECONPRVTXN(-1))))-0.0634474791568939*DURING_2009-0.3*(PAKFMLBLPOLYXN/100-((LOG(PAKNECONPRVTXN))-(LOG(PAKNECONPRVTXN(-1)))))) )) * (1-PAKNECONPRVTKN_D)+ PAKNECONPRVTKN_X*PAKNECONPRVTKN_D  $

PAKNECONPRVTKN  : HH. Cons Real
DURING_2009     : 
PAKBMFSTREMTCD  : Imp., Remittances (BOP), US$ mn
PAKBXFSTREMTCD  : Exp., Remittances (BOP), US$ mn
PAKFMLBLPOLYXN  : Key Policy Interest Rate
PAKGGEXPTRNSCN  : Current Transfers
PAKGGREVDRCTXN  : Direct Revenue Tax Rate
PAKNECONPRVTKN_A: Add factor:HH. Cons Real
PAKNECONPRVTKN_D: Fix dummy:HH. Cons Real
PAKNECONPRVTKN_X: Fix value:HH. Cons Real
PAKNECONPRVTXN  : Implicit LCU defl., Pvt. Cons., 2000 = 1
PAKNYYWBTOTLCN  : Total Wage Bill
PAKPANUSATLS    : Exchange rate LCU / US$ - Pakistan

3.5.1. The endogene property#

The endogene property either returns a list of all variables in the model that are endogenous (have an equation). It can also be used to test whether a a specific mnemonic has an equation associated with it.

The expression 'PAKNECONPRVTKN' in mpak.endogene returns True if the passed mnemonic is in the list returned by mpak.endogene.

'PAKNECONPRVTKN' in mpak.endogene
True

3.5.2. Retrieving info on many equations#

There are three functions to extract the equations from a model. They all operates on the selection pattern menionend above.

Command

Effect

mpak['PAKNECONPRVTKN'].frml

Returns a normalized version of the equation (the one actually used in modelflow)

mpak['PAKNECONPRVTKN'].eviews

In models imported from Eviews, reports the original eviews specification

mpak.PAKNECONPRVTXN.show

The equation (formula), variable descriptions variable values

The equation for consumption in mpak we see that it follows something very close to this formulation.

3.5.2.1. The .frml property#

The .frml method returns the normalized equation that is actually used in modelflow. In this instance it is not called for the results of a search operation but by referencing directly the equation (which is itself a property of the mpak model).

Note that following the normalized equation is a listing of all the dependent variables of the equation.

mpak.PAKNECONPRVTKN.frml
Endogeneous: PAKNECONPRVTKN: HH. Cons Real
Formular: FRML <DAMP,STOC> PAKNECONPRVTKN = (PAKNECONPRVTKN(-1)*EXP(PAKNECONPRVTKN_A+ (-0.2*(LOG(PAKNECONPRVTKN(-1))-LOG(1.21203101101442)-LOG((((PAKBXFSTREMTCD(-1)-PAKBMFSTREMTCD(-1))*PAKPANUSATLS(-1))+PAKGGEXPTRNSCN(-1)+PAKNYYWBTOTLCN(-1)*(1-PAKGGREVDRCTXN(-1)/100))/PAKNECONPRVTXN(-1)))+0.763938860758873*((LOG((((PAKBXFSTREMTCD-PAKBMFSTREMTCD)*PAKPANUSATLS)+PAKGGEXPTRNSCN+PAKNYYWBTOTLCN*(1-PAKGGREVDRCTXN/100))/PAKNECONPRVTXN))-(LOG((((PAKBXFSTREMTCD(-1)-PAKBMFSTREMTCD(-1))*PAKPANUSATLS(-1))+PAKGGEXPTRNSCN(-1)+PAKNYYWBTOTLCN(-1)*(1-PAKGGREVDRCTXN(-1)/100))/PAKNECONPRVTXN(-1))))-0.0634474791568939*DURING_2009-0.3*(PAKFMLBLPOLYXN/100-((LOG(PAKNECONPRVTXN))-(LOG(PAKNECONPRVTXN(-1)))))) )) * (1-PAKNECONPRVTKN_D)+ PAKNECONPRVTKN_X*PAKNECONPRVTKN_D  $

PAKNECONPRVTKN  : HH. Cons Real
DURING_2009     : 
PAKBMFSTREMTCD  : Imp., Remittances (BOP), US$ mn
PAKBXFSTREMTCD  : Exp., Remittances (BOP), US$ mn
PAKFMLBLPOLYXN  : Key Policy Interest Rate
PAKGGEXPTRNSCN  : Current Transfers
PAKGGREVDRCTXN  : Direct Revenue Tax Rate
PAKNECONPRVTKN_A: Add factor:HH. Cons Real
PAKNECONPRVTKN_D: Fix dummy:HH. Cons Real
PAKNECONPRVTKN_X: Fix value:HH. Cons Real
PAKNECONPRVTXN  : Implicit LCU defl., Pvt. Cons., 2000 = 1
PAKNYYWBTOTLCN  : Total Wage Bill
PAKPANUSATLS    : Exchange rate LCU / US$ - Pakistan

3.5.2.2. The .eviews method#

The mpak['PAKNECONPRVTKN'].eviews command returns the equations before they were normalized. In most cases this is a slightly more legible form. Here following the EViews syntax, \(\Delta ln()\) is written as dlog().

mpak['PAKNECONPRVTKN'].eviews
PAKNECONPRVTKN : DLOG(PAKNECONPRVTKN) =- 0.2*(LOG(PAKNECONPRVTKN( - 1)) - LOG(1.21203101101442) - LOG((((PAKBXFSTREMTCD( - 1) - PAKBMFSTREMTCD( - 1))*PAKPANUSATLS( - 1)) + PAKGGEXPTRNSCN( - 1) + PAKNYYWBTOTLCN( - 1)*(1 - PAKGGREVDRCTXN( - 1)/100))/PAKNECONPRVTXN( - 1))) + 0.763938860758873*DLOG((((PAKBXFSTREMTCD - PAKBMFSTREMTCD)*PAKPANUSATLS) + PAKGGEXPTRNSCN + PAKNYYWBTOTLCN*(1 - PAKGGREVDRCTXN/100))/PAKNECONPRVTXN) - 0.0634474791568939*@DURING("2009") - 0.3*(PAKFMLBLPOLYXN/100 - DLOG(PAKNECONPRVTXN))

3.5.2.3. The .show method#

The .show method returns:

  1. The description of the variable

  2. The normalized equation that is actually used in modelflow.

  3. A listing of the mnemonics and descriptions of the RHS variables

  4. The data of that variable (drawn from the basedf and .lastdf DataFrames in the model object as well as the data of the RHS variables of the equation from both the basedf and .lastdf DataFrames.

mpak.smpl(2020,2025) #change the actual sample range to limit the number of columns displayed
mpak.PAKNECONPRVTKN.show
Endogeneous: PAKNECONPRVTKN: HH. Cons Real
Formular: FRML <DAMP,STOC> PAKNECONPRVTKN = (PAKNECONPRVTKN(-1)*EXP(PAKNECONPRVTKN_A+ (-0.2*(LOG(PAKNECONPRVTKN(-1))-LOG(1.21203101101442)-LOG((((PAKBXFSTREMTCD(-1)-PAKBMFSTREMTCD(-1))*PAKPANUSATLS(-1))+PAKGGEXPTRNSCN(-1)+PAKNYYWBTOTLCN(-1)*(1-PAKGGREVDRCTXN(-1)/100))/PAKNECONPRVTXN(-1)))+0.763938860758873*((LOG((((PAKBXFSTREMTCD-PAKBMFSTREMTCD)*PAKPANUSATLS)+PAKGGEXPTRNSCN+PAKNYYWBTOTLCN*(1-PAKGGREVDRCTXN/100))/PAKNECONPRVTXN))-(LOG((((PAKBXFSTREMTCD(-1)-PAKBMFSTREMTCD(-1))*PAKPANUSATLS(-1))+PAKGGEXPTRNSCN(-1)+PAKNYYWBTOTLCN(-1)*(1-PAKGGREVDRCTXN(-1)/100))/PAKNECONPRVTXN(-1))))-0.0634474791568939*DURING_2009-0.3*(PAKFMLBLPOLYXN/100-((LOG(PAKNECONPRVTXN))-(LOG(PAKNECONPRVTXN(-1)))))) )) * (1-PAKNECONPRVTKN_D)+ PAKNECONPRVTKN_X*PAKNECONPRVTKN_D  $

PAKNECONPRVTKN  : HH. Cons Real
DURING_2009     : 
PAKBMFSTREMTCD  : Imp., Remittances (BOP), US$ mn
PAKBXFSTREMTCD  : Exp., Remittances (BOP), US$ mn
PAKFMLBLPOLYXN  : Key Policy Interest Rate
PAKGGEXPTRNSCN  : Current Transfers
PAKGGREVDRCTXN  : Direct Revenue Tax Rate
PAKNECONPRVTKN_A: Add factor:HH. Cons Real
PAKNECONPRVTKN_D: Fix dummy:HH. Cons Real
PAKNECONPRVTKN_X: Fix value:HH. Cons Real
PAKNECONPRVTXN  : Implicit LCU defl., Pvt. Cons., 2000 = 1
PAKNYYWBTOTLCN  : Total Wage Bill
PAKPANUSATLS    : Exchange rate LCU / US$ - Pakistan

Values :
  2020 2021 2022 2023 2024 2025
Base 23,672,888.34 23,972,815.36 24,164,128.02 24,427,863.05 24,818,524.47 25,323,255.17
Last 23,672,888.34 23,972,815.36 24,164,128.02 24,427,863.05 24,818,524.47 25,323,255.17
Diff 0.00 0.00 0.00 0.00 0.00 0.00
Input last run:
  2020 2021 2022 2023 2024 2025
DURING_2009 0.00 0.00 0.00 0.00 0.00 0.00
PAKBMFSTREMTCD 79.99 80.28 80.17 80.09 80.24 80.72
PAKBMFSTREMTCD(-1) 79.31 79.99 80.28 80.17 80.09 80.24
PAKBXFSTREMTCD 25,608.16 28,184.68 30,751.54 33,417.42 36,250.07 39,278.43
PAKBXFSTREMTCD(-1) 23,080.41 25,608.16 28,184.68 30,751.54 33,417.42 36,250.07
PAKFMLBLPOLYXN 6.67 7.06 7.29 7.38 7.36 7.29
PAKGGEXPTRNSCN 473,448.51 515,359.57 553,263.89 588,831.93 623,434.85 658,244.15
PAKGGEXPTRNSCN(-1) 425,736.84 473,448.51 515,359.57 553,263.89 588,831.93 623,434.85
PAKGGREVDRCTXN 4.22 4.22 4.22 4.22 4.22 4.22
PAKGGREVDRCTXN(-1) 4.22 4.22 4.22 4.22 4.22 4.22
PAKNECONPRVTKN(-1) 23,018,638.24 23,672,888.34 23,972,815.36 24,164,128.02 24,427,863.05 24,818,524.47
PAKNECONPRVTKN_A 0.01 0.00 0.00 -0.00 -0.00 -0.00
PAKNECONPRVTKN_D 0.00 0.00 0.00 0.00 0.00 0.00
PAKNECONPRVTKN_X 0.00 0.00 0.00 0.00 0.00 0.00
PAKNECONPRVTXN 1.67 1.82 1.98 2.14 2.30 2.45
PAKNECONPRVTXN(-1) 1.52 1.67 1.82 1.98 2.14 2.30
PAKNYYWBTOTLCN 30,639,578.34 33,667,219.15 36,907,411.71 40,536,234.92 44,615,868.39 49,126,944.56
PAKNYYWBTOTLCN(-1) 27,633,148.53 30,639,578.34 33,667,219.15 36,907,411.71 40,536,234.92 44,615,868.39
PAKPANUSATLS 107.18 107.01 106.84 106.69 106.57 106.45
PAKPANUSATLS(-1) 106.95 107.18 107.01 106.84 106.69 106.57
Input base run:
  2020 2021 2022 2023 2024 2025
DURING_2009 0.00 0.00 0.00 0.00 0.00 0.00
PAKBMFSTREMTCD 79.99 80.28 80.17 80.09 80.24 80.72
PAKBMFSTREMTCD(-1) 79.31 79.99 80.28 80.17 80.09 80.24
PAKBXFSTREMTCD 25,608.16 28,184.68 30,751.54 33,417.42 36,250.07 39,278.43
PAKBXFSTREMTCD(-1) 23,080.41 25,608.16 28,184.68 30,751.54 33,417.42 36,250.07
PAKFMLBLPOLYXN 6.67 7.06 7.29 7.38 7.36 7.29
PAKGGEXPTRNSCN 473,448.51 515,359.57 553,263.89 588,831.93 623,434.85 658,244.15
PAKGGEXPTRNSCN(-1) 425,736.84 473,448.51 515,359.57 553,263.89 588,831.93 623,434.85
PAKGGREVDRCTXN 4.22 4.22 4.22 4.22 4.22 4.22
PAKGGREVDRCTXN(-1) 4.22 4.22 4.22 4.22 4.22 4.22
PAKNECONPRVTKN(-1) 23,018,638.24 23,672,888.34 23,972,815.36 24,164,128.02 24,427,863.05 24,818,524.47
PAKNECONPRVTKN_A 0.01 0.00 0.00 -0.00 -0.00 -0.00
PAKNECONPRVTKN_D 0.00 0.00 0.00 0.00 0.00 0.00
PAKNECONPRVTKN_X 0.00 0.00 0.00 0.00 0.00 0.00
PAKNECONPRVTXN 1.67 1.82 1.98 2.14 2.30 2.45
PAKNECONPRVTXN(-1) 1.52 1.67 1.82 1.98 2.14 2.30
PAKNYYWBTOTLCN 30,639,578.34 33,667,219.15 36,907,411.71 40,536,234.92 44,615,868.39 49,126,944.56
PAKNYYWBTOTLCN(-1) 27,633,148.53 30,639,578.34 33,667,219.15 36,907,411.71 40,536,234.92 44,615,868.39
PAKPANUSATLS 107.18 107.01 106.84 106.69 106.57 106.45
PAKPANUSATLS(-1) 106.95 107.18 107.01 106.84 106.69 106.57
Difference for input variables
  2020 2021 2022 2023 2024 2025
DURING_2009 0.00 0.00 0.00 0.00 0.00 0.00
PAKBMFSTREMTCD 0.00 0.00 0.00 0.00 0.00 0.00
PAKBMFSTREMTCD(-1) 0.00 0.00 0.00 0.00 0.00 0.00
PAKBXFSTREMTCD 0.00 0.00 0.00 0.00 0.00 0.00
PAKBXFSTREMTCD(-1) 0.00 0.00 0.00 0.00 0.00 0.00
PAKFMLBLPOLYXN 0.00 0.00 0.00 0.00 0.00 0.00
PAKGGEXPTRNSCN 0.00 0.00 0.00 0.00 0.00 0.00
PAKGGEXPTRNSCN(-1) 0.00 0.00 0.00 0.00 0.00 0.00
PAKGGREVDRCTXN 0.00 0.00 0.00 0.00 0.00 0.00
PAKGGREVDRCTXN(-1) 0.00 0.00 0.00 0.00 0.00 0.00
PAKNECONPRVTKN(-1) 0.00 0.00 0.00 0.00 0.00 0.00
PAKNECONPRVTKN_A 0.00 0.00 0.00 0.00 0.00 0.00
PAKNECONPRVTKN_D 0.00 0.00 0.00 0.00 0.00 0.00
PAKNECONPRVTKN_X 0.00 0.00 0.00 0.00 0.00 0.00
PAKNECONPRVTXN 0.00 0.00 0.00 0.00 0.00 0.00
PAKNECONPRVTXN(-1) 0.00 0.00 0.00 0.00 0.00 0.00
PAKNYYWBTOTLCN 0.00 0.00 0.00 0.00 0.00 0.00
PAKNYYWBTOTLCN(-1) 0.00 0.00 0.00 0.00 0.00 0.00
PAKPANUSATLS 0.00 0.00 0.00 0.00 0.00 0.00
PAKPANUSATLS(-1) 0.00 0.00 0.00 0.00 0.00 0.00

3.6. Behavioural equations in the MFMod framework#

Recall a behavioural equation determines the value of an endogenous variable. For many of the variables in Wold Bank models, behavioural functions are estimated using an Error Correction Framework that splits the equation into a theoretically determined long run component and a more idiosyncratic short-run component.

Looking at the eviews representation of the consumption function:

DLOG(PAKNECONPRVTKN) =- 0.2*(LOG(PAKNECONPRVTKN( - 1)) - LOG(1.21203101101442) - LOG((((PAKBXFSTREMTCD( - 1) - PAKBMFSTREMTCD( - 1))*PAKPANUSATLS( - 1)) + PAKGGEXPTRNSCN( - 1) + PAKNYYWBTOTLCN( - 1)*(1 - PAKGGREVDRCTXN( - 1)/100))/PAKNECONPRVTXN( - 1))) + 0.763938860758873*DLOG((((PAKBXFSTREMTCD - PAKBMFSTREMTCD)*PAKPANUSATLS) + PAKGGEXPTRNSCN + PAKNYYWBTOTLCN*(1 - PAKGGREVDRCTXN/100))/PAKNECONPRVTXN) - 0.0634474791568939*@DURING("2009") - 0.3*(PAKFMLBLPOLYXN/100 - DLOG(PAKNECONPRVTXN))

Below the mnemonics are simplified to ease reading of the equation using:

Model Mnemonic

Simplified

Meaning

PAKNECONPRVTKN

\(CON^{KN}_t\)

Household Consumption

(PAKBXFSTREMTCD - PAKBMFSTREMTCD)*PAKPANUSATLS

\(Remit^{net}_t\)

Net remittances inflows in LCU

PAKGGEXPTRNSCN

\(TRANSF^{hhld}_t\)

Government transfers to households

DURING_2010

\(D^{2010}_t\)

A dummy

PAKFMLBLPOLYXN

\(r^{policy}_t\)

Policy Rate

PAKGGREVDRCTXN

\(DirectTxR_t\)

Direct Taxes: Effective rate

PAKNECONPRVTKN_A

\(CON^{KN_AF}_t\)

Add factor:Household Consumption

PAKNECONPRVTXN

\(CON^{XN}_t\)

Household Consumption Deflator

PAKNYYWBTOTLCN

\(WAGEBILL^{CN}_t\)

Economy-wide wage bill

With those substitutions the equation can be rewritten as:

\[\begin{align*} \Delta log(CON^{KN}_t) = &-0.2*\bigg[LOG(CON^{KN}_{t-1})-LOG\bigg({\frac{(Remit^{net}_{t-1}+WAGEBILL^{CN}_{t-1}+TRANSF^{hhld}_{t-1})*(1-DirectTxR_{t-1}/100)}{CON^{XN}_{t-1}}}\bigg)\bigg] \\ &+0.76*\Delta log \bigg({\frac{(Remit^{net}_{t}+WAGEBILL^{CN}_{t}+TRANSF^{hhld}_{t})*(1-DirectTxR_{t}/100)}{CON^{XN}_{t}}}\bigg) \\ &+0.030 + 0.016*D^{2010}_t-0.3*\bigg(r^{policy}_t/100-\Delta log(CON^{XN}_{t})\bigg) -CON^{KN_AF}_t \end{align*}\]

Where in this instance the short-run elasticity of consumption to disposable income is .76 , and the short run elasticity of consumption to the real interest rate is 0.3.

3.6.1. The ECM specification#

Pretty sure this repeats and earlier section. Delete one

The ECM approach used in World Bank models is described in [Wickens and Breusch, 1988], and addresses the above challenge by modelling both the long run relationship and the short run short run behaviour and brings them together into one equation.

The ECM specification is therefore a single equation comprised of two parts (the long run relationship, and the short-run relationship).

Consider as an example two variables say consumption and disposable income. Both have an underlying trend or in the parlance are co-integrated to degree 1. For simplicity we call them y an x.

3.6.1.1. The short run relationship#

In its simplest form we might have a short run relationship between the growth rates of our two variables such that:

\[\Delta ln(Y_t) = \alpha + \beta \Delta ln(X_t) +\epsilon_t\]

or substituting lower case letters for the logged values.

\[\Delta y_t = \alpha + \beta \Delta x_t +\epsilon_t\]

3.6.1.2. The long run equation#

The long run relates the level of the two (or more) variables. A simplified version of that equation can be written as:

\[Y_t=αX_t^β+ \eta_t\]

Rewriting this (in logarithms) it can be expressed as:

\[y_t = ln⁡(α) + βx_t + \eta_t\]

3.6.2. The long run equation in the steady state#

Note that in the steady state the expected value of the error term in the long run equation is zero (\(\eta_t=0 \)) so in those conditions the long run relationship can be simplified to:

\[y_t=ln⁡(α)+\beta x_t\]

or equivalently (substituting A for the log of \(\alpha\)).

\[y_t-A-βx_t=0\]

Moreover if this expression is multiplied by some arbitrary constant, say \(-\lambda\), it would still equal zero.

\[-\lambda(y_t -A-βx_t)\]

and in the steady state this will also be true for the lagged variables

\[-\lambda(y_{t-1}- A - βx_{t-1})\]

3.7. Putting it together#

From before we have the short run equation:

\[\Delta y_t = \alpha + \beta \Delta x_t +\epsilon_t\]

Inserting the steady state expression for the long-run into the short run equation makes no difference (in the long run) because in the long run it is equal to zero.

\[\Delta y_t = -\lambda(y_{t-1}-A-βx_{t-1}) + \alpha + \beta \Delta x_t +\epsilon_t\]

When the model is not in the steady state the expression \(y_{t-1}-A-βx_{t-1}\) is of course the error term from the long run equation (a measure of how far the dependent variable is from equilibrium).

3.7.1. Lambda, the speed of adjustment#

The parameter \(\lambda\) can be interpreted as the speed of adjustment. As long as \(\lambda\) is greater than zero and less or equal to one if there are no further disturbances ( \(\epsilon_t=0\)) the expression multiplied by lambda will slowly decline toward zero. How fast depends on how large or small is \(\lambda\).

To be convergent \(\lambda\) must be between 0 and 2, if its is negative or greater than one, then the long run portion of the equation will cause the disequilibrium to grow each period (\(\lambda\) >1) not diminish or if (\(\lambda\) >1<2) output will oscillate from positive to negative (\(\lambda <0\)) but will slowly converge.

Intuitively, the long-run error-term measures how far the model was from equilibrium one period earlier (at t-1). The ECM term (multiplied by \(\lambda\) ensures the model will slowly converge to equilibrium – the point at which the long run equation holds exactly. If \(\lambda\) is greater than zero but less than one (or equal to one) some portion of the previous period year’s disequilibrium will be absorbed each year. How much is absorbed depends on the size of estimated speed of the adjustment coefficient \(\lambda\).

An ECM equation can, therefore be broken into its component parts. For the consumption function it will look something like this:

\[\Delta c_t = -\lambda (\underbrace{ log(C_{t-1})-log(Wages_{t-1}-Taxes_{t-1}+Transfers_{t-1}) -log(\alpha))} _\text{Long run} +\beta \underbrace{\Delta x_t}_\text{short run}\]